﻿using System.Collections.Generic;
using System.Linq;
using TeaLight.Core.BL.Entities;

namespace TeaLight.Core.DAL
{
    public partial class SpeakerRepository
    {
        public static IEnumerable<Session> GetSessions(Speaker speaker)
        {
            return (from r in
                        (from r in SessionSpeakerRepository.GetTable()
                         where r.SpeakerId == speaker.Id
                         group r by r.SessionId)
                    join re in SessionRepository.GetTable() on r.Key equals re.Id
                    orderby re.Title
                    select re);
        }

    }
}
